﻿<template>
  <div>
      <h3>当前求和:{{$store.state.sum}}</h3>
      <select name="" id="" v-model.number="n">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
      </select>
      <button @click="add">+</button>
      <button @click="jf">-</button>
      <button @click="jAdd">当前求和为奇数再加</button>
      <button @click="delayAdd">等一等再加</button>
  </div>
</template>

<script>
    export default {
        name: 'Add',
        components:{},
        data() {
            return {
                n:1,
            }
        },
        methods: {
            add(){
                this.$store.dispatch('jia',this.n)
            },
            jf(){
                this.$store.dispatch('jian',this.n)
            },
            jAdd(){
                this.$store.dispatch('jadd',this.n)
            },
            delayAdd(){
                this.$store.dispatch('delayAdd',this.n)
            }
        },
        mounted(){ 
            console.log('Add',this)
        },
    }
</script>

<style scoped>

</style>